home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 1.2 KB | 34 lines | [TEXT/GEOL] |
- Item 7232961 8-Nov-88 07:08
-
- From: PASCOE1 Pascoe, Geoff
-
- To: D1220 VarLite, Dev, Andy Meldrum
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: Response to Class Variables...
-
- Andy,
-
- The thing about class variables (as they exist in Smalltalk) is that all
- subclasses should have access to the same variable also. By simply declaring a
- variable in the implementation subclasses in different source files normally
- don't have that type of shared access.
-
- One technique you can use to solve this- I've used variants of this frequently
- in Objective-C- is to create two methods in the class for querying and setting
- the variable. Subclasses will inherit these methods and have similar access.
- Of course you pay a speed penalty.
-
- A variant of this that is potentially more efficient is to have one method that
- returns a pointer to the class variable. If subclasses store this locally they
- don't have subsequent method call overhead.
-
- A side bonus is that unlike Smalltalk you can actually OVERRIDE the class
- variable in subclasses. This really makes it more similar to Smalltalk's CLASS
- INSTANCE VARIABLE.
-
- Geoff
-
-
-